package com.fighter.mapper;

import com.order.hit.crossover.platform.common.dao.FightOrderDao;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Lei
 * @version 0.1
 * @date 2020/9/8
 */
public interface FightOrderMapper {

    @Select("select * from fight_order")
    @Results({
            @Result(property = "id", column = "ID"),
            @Result(property = "storeId", column = "store_id"),
            @Result(property = "storeName", column = "store_name"),
            @Result(property = "storeLocation", column = "store_location"),
            @Result(property = "userId", column = "user_id"),
            @Result(property = "userName", column = "user_name"),
            @Result(property = "fightOrderState", column = "fightOrderState"),
            @Result(property = "userNum", column = "userNum"),
            @Result(property = "nowNum", column = "nowNum"),
            @Result(property = "participaters", column = "participaters"),
            @Result(property = "goodName", column = "good_name"),
            @Result(property = "goodNumber", column = "good_number"),
            @Result(property = "goodType", column = "good_type"),
            @Result(property = "price", column = "price"),
            @Result(property = "start_time", column = "start_time"),
            @Result(property = "end_time", column = "end_time")
    })
    public List<FightOrderDao> getAllFightOrder();

    @Select("select * from fight_order where fightOrderState=#{state}")
    @Results({
            @Result(property = "id", column = "ID"),
            @Result(property = "storeId", column = "store_id"),
            @Result(property = "storeName", column = "store_name"),
            @Result(property = "storeLocation", column = "store_location"),
            @Result(property = "userId", column = "user_id"),
            @Result(property = "userName", column = "user_name"),
            @Result(property = "fightOrderState", column = "fightOrderState"),
            @Result(property = "userNum", column = "userNum"),
            @Result(property = "nowNum", column = "nowNum"),
            @Result(property = "participaters", column = "participaters"),
            @Result(property = "goodName", column = "good_name"),
            @Result(property = "goodNumber", column = "good_number"),
            @Result(property = "goodType", column = "good_type"),
            @Result(property = "price", column = "price"),
            @Result(property = "start_time", column = "start_time"),
            @Result(property = "end_time", column = "end_time")
    })
    public List<FightOrderDao> getAllDisplayFightOrder(@Param("state") String state);


    @Select("select * from fight_order where store_id=#{store_id}")
    @Results({
            @Result(property = "id", column = "ID"),
            @Result(property = "storeId", column = "store_id"),
            @Result(property = "storeName", column = "store_name"),
            @Result(property = "storeLocation", column = "store_location"),
            @Result(property = "userId", column = "user_id"),
            @Result(property = "userName", column = "user_name"),
            @Result(property = "fightOrderState", column = "fightOrderState"),
            @Result(property = "userNum", column = "userNum"),
            @Result(property = "nowNum", column = "nowNum"),
            @Result(property = "participaters", column = "participaters"),
            @Result(property = "goodName", column = "good_name"),
            @Result(property = "goodNumber", column = "good_number"),
            @Result(property = "goodType", column = "good_type"),
            @Result(property = "price", column = "price"),
            @Result(property = "start_time", column = "start_time"),
            @Result(property = "end_time", column = "end_time")
    })
    public List<FightOrderDao> getStoresOrder(@Param("store_id") String store_id);



    @Select("select * from fight_order where user_id=#{userId}")
    @Results({
            @Result(property = "id", column = "ID"),
            @Result(property = "storeId", column = "store_id"),
            @Result(property = "storeName", column = "store_name"),
            @Result(property = "storeLocation", column = "store_location"),
            @Result(property = "userId", column = "user_id"),
            @Result(property = "userName", column = "user_name"),
            @Result(property = "fightOrderState", column = "fightOrderState"),
            @Result(property = "userNum", column = "userNum"),
            @Result(property = "nowNum", column = "nowNum"),
            @Result(property = "participaters", column = "participaters"),
            @Result(property = "goodName", column = "good_name"),
            @Result(property = "goodNumber", column = "good_number"),
            @Result(property = "goodType", column = "good_type"),
            @Result(property = "price", column = "price"),
            @Result(property = "start_time", column = "start_time"),
            @Result(property = "end_time", column = "end_time")
    })
    public List<FightOrderDao> getUsersOrder(@Param("userId") int userId);

    @Select("select * from fight_order where ID=#{ID}")
    @Results({
            @Result(property = "id", column = "ID"),
            @Result(property = "storeId", column = "store_id"),
            @Result(property = "storeName", column = "store_name"),
            @Result(property = "storeLocation", column = "store_location"),
            @Result(property = "userId", column = "user_id"),
            @Result(property = "userName", column = "user_name"),
            @Result(property = "fightOrderState", column = "fightOrderState"),
            @Result(property = "userNum", column = "userNum"),
            @Result(property = "nowNum", column = "nowNum"),
            @Result(property = "participaters", column = "participaters"),
            @Result(property = "goodName", column = "good_name"),
            @Result(property = "goodNumber", column = "good_number"),
            @Result(property = "goodType", column = "good_type"),
            @Result(property = "price", column = "price"),
            @Result(property = "start_time", column = "start_time"),
            @Result(property = "end_time", column = "end_time")
    })
    public FightOrderDao getOrderById(@Param("ID") Long  id);


    @Insert("insert into fight_order (ID, store_id, store_name, store_location, user_id, user_name, fightOrderState, userNum, nowNum, participaters, good_name, good_number, good_type, price, start_time, end_time)" +
            "VALUES" +
            "(#{id}, #{storeId}, #{storeName}, #{storeLocation}, #{userId}, #{userName}, #{fightOrderState}, #{userNum}, #{nowNum}, #{participaters}, #{goodName}, #{goodNumber}, #{goodType}, #{price}, #{start_time}, #{end_time})")
    public void insertFightOrder(FightOrderDao fightOrderDao);

    @Update("update fight_order set " +
            "store_id=#{storeId}, store_name=#{storeName}, store_location=#{storeLocation}, user_id=#{userId}, user_name=#{userName}, " +
            "fightOrderState=#{fightOrderState}, userNum=#{userNum}, nowNum=#{nowNum}, participaters=#{participaters}, " +
            "good_name=#{goodName}, good_number=#{goodNumber}, good_type=#{goodType}, price=#{price}, start_time=#{start_time}, end_time=#{end_time} where ID=#{id}")
    public void updateOrder(FightOrderDao fightOrderDao);


    @Delete("delete from fight_order where ID=#{id}")
    public void deleteOrder(@Param("id") int id);


}
